<?xml version="1.0" encoding="ISO-8859-1" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:composite="http://java.sun.com/jsf/composite">
 <h:head>
 
   <title>Componente reutilizable para la seleccion de lugares</title>
 
 </h:head>
 
 <h:body>
     
   <composite:interface displayName="Componente para seleccionar lugares del Peru" >
      <composite:attribute name="entity" required="true" />
      <!-- composite:attribute name="field"  required="true" /-->
      <composite:attribute name="columns"  required="true" default="2"/>
      <!--composite:attribute name="label"  required="false" default="#{cc.attrs.entity.class.simpleName}.#{cc.attrs.field}" />
      <composite:attribute name="required" required="false" default="false" /-->
   </composite:interface>
 
   <composite:implementation>
       <h:panelGrid rendered="#{cc.attrs.columns=='2'}" columns="#{cc.attrs.columns}">
       <h:outputLabel value="Departamento:" />
		<h:selectOneMenu value="#{cc.attrs.entity['codDepto']}" style="width:100px">
		<f:selectItems value="#{cc.attrs.entity['departamentos']}" />
		<f:ajax render="cboProv cboDist" />
		</h:selectOneMenu>
		<h:outputLabel value="Provincia:" />
		<h:selectOneMenu id="cboProv" value="#{cc.attrs.entity['codProv']}" style="width:150px">
		<f:selectItems value="#{cc.attrs.entity['provincias']}" />
		<f:ajax render="cboDist" />
		</h:selectOneMenu>
		<h:outputLabel value="Distrito:" />
		<h:selectOneMenu id="cboDist" value="#{cc.attrs.entity['codDist']}" style="width:150px">
		<f:selectItems value="#{cc.attrs.entity['distritos']}" />
		</h:selectOneMenu>
		<h:inputHidden value="#{cc.attrs.entity['codAmbito']}" />
        </h:panelGrid>
   
      <h:panelGrid rendered="#{cc.attrs.columns=='3'}" columns="#{cc.attrs.columns}">
       <h:outputLabel value="Departamento:" />
       <h:outputLabel value="Provincia:" />
       <h:outputLabel value="Distrito:" />
		<h:selectOneMenu value="#{cc.attrs.entity['codDepto']}" style="width:100px">
		<f:selectItems value="#{cc.attrs.entity['departamentos']}" />
		<f:ajax render="cboProv1 cboDist1" />
		</h:selectOneMenu>
		
		<h:selectOneMenu id="cboProv1" value="#{cc.attrs.entity['codProv']}" style="width:150px">
		<f:selectItems value="#{cc.attrs.entity['provincias']}" />
		<f:ajax render="cboDist1" />
		</h:selectOneMenu>
		
		<h:selectOneMenu id="cboDist1" value="#{cc.attrs.entity['codDist']}" style="width:150px">
		<f:selectItems value="#{cc.attrs.entity['distritos']}" />
		</h:selectOneMenu>
		<h:inputHidden value="#{cc.attrs.entity['codAmbito']}" />
        </h:panelGrid>
   
    
   </composite:implementation>
 
 </h:body>
 
</html>